package es

import (
	"context"

	es "github.com/olivere/elastic/v7"
)

type IEsClient interface {
	Search(index string) IEsSearcher
}

type IEsSearcher interface {
	// Searcher() *es.SearchService
	Searcher() *es.SearchService

	// 排序
	Sort(field string, asc bool, unmaptag ...string) IEsSearcher

	// 分页
	Page(pageNum, pageSize int) IEsSearcher

	// 自定义查询
	Query(q es.Query) IEsSearcher

	// bool条件查询
	WhereAnd(q func(*es.BoolQuery)) IEsSearcher

	// 执行查询
	Do(ctx ...context.Context) *ESResult

	// 执行查询 & 解析结果
	Scan(data any) error
}
